<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>酒店列表</title>
    <script src="__PUBLIC__/echarts/echarts.min.js"></script>
    <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="__PUBLIC__/font-awesome/css/font-awesome.min.css" media="all">
    <link rel="stylesheet" href="__CSS__/admin.css"  media="all">
</head>
<body>
<div class="layui-fluid main">
    <fieldset class="layui-elem-field site-demo-button" style="margin-top: 30px;border:0">
        <form class="layui-form serch" action="{:url('admin/hotel/index')}" method="post">
            <div class="layui-form-item" style="float: left;">
                <div class="layui-input-inline">
                    <input type="text" name="keywords" autocomplete="off" value="{notempty name='$hotelParams.keywords'}{$hotelParams.keywords}{/notempty}" lay-verify="title" placeholder="请输入id/名称/地址" class="layui-input layui-btn-sm">
                </div>

                <div class="layui-input-inline">
                    <div class="layui-inline">
                        <select name="city_id" lay-search="" autocomplete="off">
                            <option value="">请选择</option>
                            {notempty name="$cityList"}
                            {volist name="$cityList" id="value"}
                            <option value="{$value.id}" {notempty name="$hotelParams.city_id"}{if $hotelParams.city_id==$value.id}selected{/if}{/notempty}>{$value.name}</option>
                            {/volist}
                            {/notempty}
                        </select>
                    </div>
                </div>

                <button class="layui-btn layui-btn-default layui-btn-sm" lay-submit="" lay-filter="serch" id="search">查询</button>
                <a class="layui-btn layui-btn-normal layui-btn-sm addNewHotel">新增酒店</a>
            </div>
        </form>

    </fieldset>
    <table class="layui-table" lay-even="" lay-skin="line">
        <colgroup>
            <col width="10%">
            <col width="20%">
            <col width="20%">
            <col width="20%">
            <col width="20%">
            <col width="10%">
        </colgroup>
        <thead>
        <tr>
            <th>ID</th>
            <th>名称</th>
            <th>城市</th>
            <th>来源</th>
            <th>市场价</th>
            <th>销售价</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        {if !empty($list)}
        {volist name="list" id="vo"}
        <tr>
            <td>{$vo.hotel_id}</td>
            <td>{$vo.name}</td>
            <td>{$vo.city_name}</td>
            <td>{if empty($vo.channel)}自营{else}{$vo.channel}{/if}</td>
            <td>{$vo.market_price}</td>
            <td>{$vo.sales_price}</td>
            <td>
                <a href="{:url('admin/hotel/addNewHotel',['id'=>$vo.hotel_id])}" class="jumpUrl layui-btn layui-btn-xs layui-btn-normal" target="_blank"  style="margin:4px 0 0 10px;font-size:12px;">查看酒店</a>
                {if empty($vo.channel)}
                <a href="{:url('admin/hotel/setRoomSkuPrice',['id'=>$vo.hotel_id])}" class="jumpUrl layui-btn layui-btn-xs layui-btn-warm" target="_blank"  style="margin:4px 0 0 10px;font-size:12px;">设置价格</a>
                {elseif $vo.channel=="dida"}
                <a href="{:url('admin/hotel/didaindex',['HotelName'=>$vo.source_id])}" class="jumpUrl layui-btn layui-btn-xs layui-btn-default" target="_blank"  style="margin:4px 0 0 10px;font-size:12px;">查看价格</a>
                {elseif $vo.channel=="teamAmerica"}
                <a href="{:url('admin/hotel/search',['VendorID'=>$vo.source_id,'CityCode'=>$vo.details.CityCode,'NumberOfRooms'=>1,'adult'=>2,'child'=>0])}" class="jumpUrl layui-btn layui-btn-xs layui-btn-default" target="_blank"  style="margin:4px 0 0 10px;font-size:12px;">查看价格</a>
                {/if}
                <a href="{:url('admin/hotel/delHotel',['id'=>$vo.hotel_id])}" class="delHotel layui-btn layui-btn-xs layui-btn-danger" target="_blank"  style="margin:4px 0 0 10px;font-size:12px;">删除酒店</a>
            </td>
        </tr>
        {/volist}
        {/if}
        </tbody>
    </table>
    <div>{$list->render()}</div>
</div>
</body>
<script src="__PUBLIC__/layui/layui.js"></script>
<script src="__PUBLIC__/jquery/jquery.min.js"></script>
<script>
    layui.use(['layer','form'], function() {
        var layer = layui.layer;
        var form = layui.form;

        //新增酒店
        $(".addNewHotel").click(function(){
            var url = '{:url("admin/hotel/addNewHotel")}';
            layer.open({
                title:'新增酒店',
                type:2,
                area:['80%','80%'],
                content:url,
                end:function () {
                    window.location.reload();
                }
            })
        })

        $(".jumpUrl").click(function () {
            var url = $(this).attr('href');
            layer.open({
                title:'信息',
                type:2,
                area:['90%','90%'],
                content:url,
                end:function () {
                    window.location.reload();
                }
            })
            return false;
        })

        $(".delHotel").click(function () {
            var url = $(this).attr('href');
            layer.confirm('确认删除该酒店信息?',function(){
                //开启加载logo
                var add_load_index = layer.load(2,{shade: [0.5, '#393D49']});
                $.post(url,{},function (res) {
                    layer.close(add_load_index);
                    layer.msg(res.msg);
                    if(res.code == 1) {
                        setTimeout(function(){
                            window.location.reload();
                        },1500)
                    }
                },'json')
            })
            return false;
        })
    });

</script>
</html>
